package com.example;

import com.example.pojo.UserBean;
import com.example.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;


@Controller
@RequestMapping(value = "/")
public class IndexController {

    @Autowired
    private IUserService userService;

    @ResponseBody
    @RequestMapping(value = "/get")
    public UserBean get() {

        return userService.getUserById(1);

    }


    @ResponseBody
    @RequestMapping(value = "/update")
    public UserBean update() {
        Date date = new Date();
        UserBean user = userService.getUserById(1);
        user.setCreateTime(date);
        user.setUserName("test");
        return userService.update(user);
    }

    @ResponseBody
    @RequestMapping(value = "/del")
    public String del() {
        return userService.del(1);
    }

}